#include "Stack.h"
#include <assert.h>

Stack::Stack()
{
	list = new LinkedList();
	list->InitList();
}

Stack::~Stack()
{
	list->ClearList();
	delete list;
}

int Stack::Pop()
{
	assert(!IsEmpty());
	int data = list->GetData(1);
	list->DeleteListFirst();
	return data;
}

void Stack::Push(int data)
{
	list->InsertListFirst(new LinkedListNode(data));
}

bool Stack::IsEmpty()
{
	return list->IsListEmpty();
}

int Stack::Peek()
{
	assert(!IsEmpty());
	return list->GetData(1);
}